var path = window.location.pathname.split('.')[0].split('/')[2];
if(path != ''){
  $('.'+path).addClass('active');
}else {
  $('.index').addClass('active');
}
var tpl  =  $("#myTemplate").html();
var template = Handlebars.compile(tpl);
$.ajax({
    url:"/project/join.json",
    type:"get",
    dataType:"json",
    data:{
        pageSize:10
    },
    success:function(data){
        $('#pagination').jqPaginator({
            totalPages: data.data.totalPages,
            visiblePages: 10,
            currentPage: 1,
            onPageChange:function(currentPage,type){
                $.ajax({
                    url:"/project/join.json",
                    type:"get",
                    dataType:"json",
                    success:function(data){
                        var html = template(data);
                        $('.project-content').empty();
                        $('.project-content').append(html);
                    },
                    error: function(msg) {
                        console.log(msg)
                    }
                })
            },
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">尾页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);" class="page-a">{{page}}</a></li>',
        });
        var html = template(data);
        $('.project-content').empty();
        $('.project-content').append(html);
    },
    error: function(msg) {
        console.log(msg)
    }
});